package ru.voronoy.thefifteen.entity;

import java.text.SimpleDateFormat;
import java.util.Date;

public class Record implements IRecord, Comparable<Record> {
	private String name;
	private String result;

	public Record(String name, String result) {
		this.name = name;
		this.result = result;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getName() {
		return name;
	}

	public void setResult(String result) {
		this.result = result;
	}

	public String getResult() {
		return result;
	}

	@Override
	public int compareTo(Record o) {
		// TODO Auto-generated method stub
		Date thisDate = null;
		Date otherDate = null;
		try {
			SimpleDateFormat df = new SimpleDateFormat("HH:mm:ss");
			thisDate = df.parse(this.result);
			otherDate = df.parse(o.result);
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		return thisDate.compareTo(otherDate);
	}
}
